import { useRoutes } from 'react-router-dom';
import type { RouteObject } from 'react-router-dom';
import { lazy } from 'react';

const Home = lazy(() => import('@/views/Home'));
const Message = lazy(() => import('@/views/Message'));
const My = lazy(() => import('@/views/My'));

type RouteItem = RouteObject & {
  name: string;
  title: string;
};

export const routesList: RouteItem[] = [
  {
    path: '/',
    name: 'App',
    Component: Home,
    title: '首页'
  },
  {
    path: '/message',
    name: 'message',
    Component: Message,
    title: '消息'
  },
  {
    path: '/my',
    name: 'my',
    Component: My,
    title: '我的'
  },
]

function RenderRouter() {
  const element = useRoutes(routesList);
  return element;
}
export default RenderRouter